﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PoolControl : MonoBehaviour {

	public static PoolControl instance;

	public WeaponPool gatlinPool;//加特林对象池
	public WeaponPool cannonPool;//加农炮对象池
	public WeaponPool missilePool;//导弹对象池
	public WeaponPool laserPool;//激光对象池
	public WeaponPool jumppingMissilePool;//跳跃导弹对象池
	public WeaponPool assaultMissilePool;//突击导弹对象池
	public WeaponPool cruiseMissilePool;//巡航导弹对象池
	public WeaponPool burningMissilePool;//燃烧导弹对象池
	public WeaponPool shipTorpedoPool;//对舰鱼雷
	public WeaponPool cruiseAssaultMissilePool;//巡航突击导弹对象池

	public GameObject gatlinPrefab;
	public GameObject cannonPrefab;
	public GameObject missilePrefab;
	public GameObject laserPrefab;
	public GameObject jummpMissilePrefab;
	public GameObject assaultMissilePrefab;
	public GameObject cruiseMissilePrefab;
	public GameObject burningMissilePrefab;
	public GameObject shipTorpedoPrefab;
	public GameObject cruiseAssaultMissilePrefab;

	/// <summary>
	/// Awake is called when the script instance is being loaded.
	/// </summary>
	void Awake()
	{
		instance = this;
		gatlinPool = new WeaponPool(50, gatlinPrefab, (gameObject) => {ResetInit(gameObject);}, (gameObject) => {OneTimeInit(gameObject);});
		cannonPool = new WeaponPool(50, cannonPrefab, (gameObject) => {ResetInit(gameObject);}, (gameObject) => {OneTimeInit(gameObject);});
		missilePool = new WeaponPool(50, missilePrefab, (gameObject) => {ResetInit(gameObject);}, (gameObject) => {OneTimeInit(gameObject);});
		laserPool = new WeaponPool(50, laserPrefab, (gameObject) => {ResetInit(gameObject);}, (gameObject) => {OneTimeInit(gameObject);});
		jumppingMissilePool =  new WeaponPool(50, jummpMissilePrefab, (gameObject) => {ResetInit(gameObject);}, (gameObject) => {OneTimeInit(gameObject);});
		assaultMissilePool =  new WeaponPool(50, assaultMissilePrefab, (gameObject) => {ResetInit(gameObject);}, (gameObject) => {OneTimeInit(gameObject);});
		cruiseMissilePool =  new WeaponPool(50, cruiseMissilePrefab, (gameObject) => {ResetInit(gameObject);}, (gameObject) => {OneTimeInit(gameObject);});
		burningMissilePool =  new WeaponPool(50, burningMissilePrefab, (gameObject) => {ResetInit(gameObject);}, (gameObject) => {OneTimeInit(gameObject);});
		shipTorpedoPool =  new WeaponPool(50, shipTorpedoPrefab, (gameObject) => {ResetInit(gameObject);}, (gameObject) => {OneTimeInit(gameObject);});
		cruiseAssaultMissilePool =  new WeaponPool(50, cruiseAssaultMissilePrefab, (gameObject) => {ResetInit(gameObject);}, (gameObject) => {OneTimeInit(gameObject);});
	}

	// Use this for initialization
	void Start () {
		// print("实例化pool");
		// gatlinPool = new WeaponPool(50, gatlinPrefab, (gameObject) => {ResetInit(gameObject);}, (gameObject) => {OneTimeInit(gameObject);});
		// cannonPool = new WeaponPool(50, cannonPrefab, (gameObject) => {ResetInit(gameObject);}, (gameObject) => {OneTimeInit(gameObject);});
		// missilePool = new WeaponPool(50, missilePrefab, (gameObject) => {ResetInit(gameObject);}, (gameObject) => {OneTimeInit(gameObject);});
		// laserPool = new WeaponPool(50, laserPrefab, (gameObject) => {ResetInit(gameObject);}, (gameObject) => {OneTimeInit(gameObject);});
	}

	void OneTimeInit(GameObject gameObject)
	{
		gameObject.transform.position = new Vector3(1000, 1000, 0);
	}
	
	void ResetInit(GameObject gameObject)
	{
		
	}


	// Update is called once per frame
	void Update () {
		
	}
}
